import { useToggle } from '@vueuse/core';
import { defineStore } from 'pinia';

/**
 * 页面加载或请求时的loading状态
 * 
 * @returns loading
 * @returns onToggleLoading 切换loading状态
 */
export const useLoadingStore = defineStore('loadingStore', (initialValue?: boolean) => {
  const [loading, onToggleLoading] = useToggle(initialValue || false);
  return { loading, onToggleLoading };
});
